Skip to content

Disable AndroidEnableMarshalMethods to fix silent startup crash - #204

Merged
winnerspiros merged 1 commit into
masterfrom
copilot/fix-osu-apk-crash
Apr 19, 2026
Merged

Disable AndroidEnableMarshalMethods to fix silent startup crash#204
winnerspiros merged 1 commit into
masterfrom
copilot/fix-osu-apk-crash

Conversation

Copilot AI commented Apr 19, 2026

Copy link
Copy Markdown

After the EnableLLVM fix (PR #203), the APK still crashes on startup — black screen, screen rotates to landscape, then dies with no crash logs.

The absence of managed exception output is the key signal: AndroidEnableMarshalMethods=true generates build-time P/Invoke stubs that execute in native code, bypassing managed exception handling entirely. When combined with profiled AOT + trimming, the generated stubs can produce invalid native calls (silent SIGSEGV/SIGABRT).

  • Set AndroidEnableMarshalMethods=false in osu.Android.props — reverts to runtime-generated P/Invoke trampolines which handle partial AOT correctly
<!-- Before -->
<AndroidEnableMarshalMethods>true</AndroidEnableMarshalMethods>

<!-- After -->
<AndroidEnableMarshalMethods>false</AndroidEnableMarshalMethods>

The crash timeline matches: LoadComplete() fires the first P/Invoke (nGetBigCoreMask/nSetThreadAffinity) after orientation is applied — consistent with "black screen → rotation → crash" sequence. The ~5-10% P/Invoke overhead is negligible since hot-path audio uses UnmanagedCallersOnly function pointers, not DllImport.

… logs

AndroidEnableMarshalMethods=true generates build-time P/Invoke stubs that can
crash in native code when combined with profiled AOT + trimming. The crash
bypasses managed exception handling, producing no crash logs — matching the
reported symptoms (black screen, rotated screen, silent crash).

The default runtime-generated P/Invoke trampolines are used instead.

Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/900d2a81-5771-4a37-ab0c-f6d9bf79386e

Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
@gitar-bot

gitar-bot Bot commented Apr 19, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@winnerspiros
winnerspiros marked this pull request as ready for review April 19, 2026 07:32
Copilot AI review requested due to automatic review settings April 19, 2026 07:32
@winnerspiros
winnerspiros merged commit effc01e into master Apr 19, 2026
2 of 16 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Disables build-time generated P/Invoke marshal stubs on .NET 10 Android to avoid silent native startup crashes when using profiled AOT + trimming, reverting to the runtime-generated trampolines.

Changes:

  • Set AndroidEnableMarshalMethods to false in osu.Android.props.
  • Replace the previous performance-focused comment with a crash-risk explanation specific to profiled AOT + trimming.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants